package com.kk.xhr.model.dao.custom;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

/**
 * 自定义部门mapper
 *
 * @author kkmystery
 * @version 1.0 2021/3/4
 * @since 1.0.0
 */
@Mapper
public interface RoleCustomMapper {

    /**
     * 根据用户id连接查询拥有的角色
     *
     * @param userId 用户id
     * @return 角色列表
     */
    @Select("select r.name from user_role ur " +
        "left join role r on r.id = ur.role_id" +
        "where ur.user_id = #{userId} and r.status = 1 " +
        "ORDER BY r.order")
    Set<String> queryRolesByUserId(@Param("userId") Long userId);
}
